package org.light.framework.orm;

import java.util.ArrayList;

/**
 * 普通列关联信息
 * @author de.cel
 *
 */
public class ColumnInfo {

	public String name;
	public String dbType;
	public int length;
	public int cascade;
	public boolean readOnly;
	
	public String propertyName;

	/**
	 * 根据属性名称查找列信息
	 * @param infos
	 * @param propertyName
	 * @return
	 */
	public static ColumnInfo findByPropertyName(ArrayList<ColumnInfo> infos,String propertyName){
		
		for (ColumnInfo columnInfo : infos) {
			if(columnInfo.propertyName.equals(propertyName))
				return columnInfo;
		}
		
		return null;
	}
	
	/**
	 * 根据属性名称查找列信息
	 * @param infos
	 * @param propertyName
	 * @return
	 */
	public static ColumnInfo findByName(ArrayList<ColumnInfo> infos,String name){
		
		for (ColumnInfo columnInfo : infos) {
			if(columnInfo.name.equals(name))
				return columnInfo;
		}
		
		return null;
	}
}
